package top.codehelen.api.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.codehelen.pojo.Stu;
import top.codehelen.service.StuService;

/**
 * @Classname StuController
 * @Description StuController
 * @Date 2021/5/14 1:41 下午
 * @Created by helen
 */
@RestController
@RequestMapping("/stu")
public class StuController {


    @Autowired
    private StuService stuService;



    @PostMapping("/save")
    public String stuTest(@RequestBody Stu stu){

        System.out.println(JSON.toJSONString(stu));
        stuService.save(stu);
        System.out.println(stu);

        return "SUCCESS";
    }

    @GetMapping("/getOne")
    public Stu getStu(Integer id) {
        Stu byId = stuService.getById(id);
        System.out.println(JSON.toJSONString(byId));
        return byId;


    }
}
